<?xml version="1.0" encoding="UTF-8"?>
<Automata namespaceName="Condenser" className="VBCondenser" baseClass="Condenser">

  <!-- literal code added to the generated class -->
	<ClassCode>
    // returns true iff c is an identifier character (alphanumeric or '_')
		protected bool isIdent(char c) {
		  return (('A'&lt;=c&amp;&amp;c&lt;='Z')||('a'&lt;=c&amp;&amp;c&lt;='z')||('0'&lt;=c&amp;&amp;c&lt;='9')||(c=='_'));
		}
	</ClassCode>

	<ClassCode>
    // makes all line breaks into &quot;\n&quot; format
    protected string fixLineBreaks(string s) {
      StringWriter output=new StringWriter();
      int i=0;
      for(;i+1&lt;s.Length;++i) {
        string ss=s.Substring(i,2);
        if(ss=="\r\n"||ss=="\n\r") {
          output.Write('\n');
          ++i;
          continue;
        }
        else if(s[i]=='\r')
          output.Write('\n');
        else
          output.Write(s[i]);
      }
      if(i&lt;s.Length) {
        if(s[i]=='\r')
          output.Write('\n');
        else
          output.Write(s[i]);
      }
      return output.ToString();
    }
	</ClassCode>
  
  <!-- state for the begninning of a line, until the first non-whitespace char -->
	<State stateName="BLANK_LINE" initial="true">
		<Trans charSet=" \t\n" echo="false"/>
		<Trans next="LINE" replace="true" echo="false"/>
	</State>

  <!-- state for a line after some non-whitespace char -->
	<State stateName="LINE">
		<Trans string="'" next="COMMENT"/>
		<Trans char="&quot;" next="STRING"/>
		<Trans testMethod="isIdent" next="CODE_IDENT"/>
		<Trans charSet=" \t" next="LINE" echo="false"/>
		<Trans charSet="\n" next="BLANK_LINE"/>
		<Trans />
	</State>

  <!-- state after seeing a identifier char (alpha-numeric or '_') -->
	<State stateName="CODE_IDENT"> 
		<Trans testMethod="isIdent"/>
		<Trans charSet=" \t" next="CODE_IDENT_WS" echo="false"/>
		<Trans next="LINE" replace="true" echo="false"/>
	</State>

  <!-- white space beginning with an identifier char prints 1 space if it also ends with an identifier, otherwise none -->
	<State stateName="CODE_IDENT_WS"> 
		<Trans charSet=" \t" echo="false"/>
		<Trans string="_\n" echo="false"/>
		<Trans testMethod="isIdent" next="LINE" replace="true" echo="false">output.Write(' ');
		</Trans>
		<Trans next="LINE" replace="true" echo="false"/>
	</State>

  <!-- comment, echo everything to end of line -->
	<State stateName="COMMENT">
		<Trans charSet="\n" next="BLANK_LINE"/>
		<Trans />
	</State>
	
  <!-- string, echo everything -->
	<State stateName="STRING">
		<Trans string="\&quot;\&quot;"/>
		<Trans char="&quot;" next="LINE"/>
		<Trans/>
	</State>

</Automata>

